<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link th:replace="fragments/dependency :: edit-css">

<title>优铺Admin</title>
</head>

<body>
	<div class="right_col" style="background: #F7F7F7">
		<div class="row">
			<div class="col-md-12 col-sm-12 col-xs-12">
				<div class="x_panel">
					<div class="x_title">
						<h2>添加模块</h2>

						<div class="clearfix"></div>
					</div>
					<div class="x_content">
						<br>
						<form id="demo-form2" class="form-horizontal form-label-left">
						
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">
									所属栏目: <span class="required" th:text="${pageType}"></span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input type="hidden" name="pageType" required="required" th:value="${pageType}">
								</div>
							</div>
							
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">
									模块名称 <span class="required">*</span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input type="text" name="name" required="required"
										class="form-control col-md-7 col-xs-12">
								</div>
							</div>

							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">
									展示形式 <span class="required">*</span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<select class="form-control" id="showType" name="showType">
										<option value="" selected>请选择</option>
										<option th:each="showType:${showType}" th:value="${showType}" th:if="${showType.name() != '自定义'}"
											th:text="${showType}"></option>
									</select>
								</div>
							</div>
							
							<div class="ln_solid"></div>
							<div class="form-group">
								<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
									<button class="btn btn-primary" type="reset">重置</button>
									<button type="button" id="save" class="btn btn-success">提交</button>
								</div>
							</div>

						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="fragments/dependency :: edit-js"></div>
	<script type="text/javascript">
		var add = {
			init : function() {
				add.initValidate();
				$("#save").on('click', function() {
					$('form').submit();
				});
			},
			initValidate : function() {
				formValidator.rules = {
						chinese: [/^[\u4E00-\u9FA5A-Za-z0-9_]+$/, ""]
				};

				formValidator.fields = {
					name : 'required;chinese;',
					showType : 'required;',

				};
				//表单提交的实体获取函数
				formValidator.getEntity = function() {
					return {
						name : $("input[name=name]").val(),
						pageType : $("input[name=pageType]").val(),
						showType : $("#showType").val(),
						status : 100,
					};
				}
				//初始化验证路径以及回调函数
				formValidator.init('/pageModule/add', function(data) {
					if (data.id > 0) {
						adminLayer.alert({
							content : '添加成功',
							yes : function() {
								window.parent.location.reload();
							},
							end : function() {

							}
						});
					}
				});
			}
		}
		add.init();
	</script>


</body>
</html>
